{include file="public_iframe:head"}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>数据导入</h5>
            <div class="ibox-tools" style="margin-top: -9px;">
                <a href="javascript:history.go(-1);" class="btn btn-primary"><i class="fa fa-arrow-left"></i> 返回</a>
            </div>
        </div>
        <div class="ibox-content">
            <form action="" method="post" enctype="multipart/form-data" id="brandForm" class="form-horizontal">
                <div class="form-group">
                    <label class="col-sm-2 control-label">数据文件</label>
                    <div class="col-sm-6">
                        <input type="file" class="textbox textbox_295" name="file" id=""  value=""/>&nbsp;&nbsp;注：只能上传Excles文件,并且最好每个文件以1000条数据为适,当数据过大时请耐心等待不要关闭浏览器
                    </div>
                </div>
                <div class="hr-line-dashed"></div>
                <div class="form-group">
                    <div class="col-sm-4 col-sm-offset-2">
                        <!--<button class="btn btn-primary" type="submit">提交</button>-->
                        <!--href="JavaScript:void(0);" onclick="roleSubmit();"-->
                        <a href="JavaScript:void(0);" onclick="Submit();" class="btn btn-primary" id="submit">提交</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!-- End Panel Basic -->
</div>
<script>
    function Submit(){
        var file = $(':file')[0].files[0];
        if(file){
          var file_name = $(':file')[0].files[0].name;
        }

        var formData = new FormData();
        formData.append('file',file);
        formData.append('file_name',file_name);

        $.ajax({
          url:"{:url('Loan/import')}",
          type:'POST',
          data:formData,
          async:true,
          processData:false,
          contentType:false,
          beforeSend: function(){  
               ityzl_SHOW_LOAD_LAYER();
          }, 
          success:function(result){
              if(result.code == '0'){
                  parent.layer.alert(result.msg,{
                      skin: 'layui-layer-molv', //样式类名
                      btn: ['确定']
                  });
              }else{
                  var indexs = parent.layer.alert(result.msg, {
                      skin: 'layui-layer-molv', //样式类名
                      btn: ['确定']
                  },
                  function (index, item) {
                    parent.layer.close(indexs);
                    //location.href = result.url;
                  });
              }
          }
          
        });
    }

    function ityzl_SHOW_LOAD_LAYER(){
      parent.layer.msg('导入中...', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: '0px', time:1800*1000}) ;  
    }
</script>
